/**
 * Licensed by the Bunie Developmentgroup.
 */
package Protocol;

import java.util.ArrayList;

/**
 * @author Wouter
 */
public class AccountManagementResponsePacket extends BasicPacket {
    private ArrayList<String[]> result;
    private int succesfullAddEditDelete = -1;

    /**
     * Constructor of the AccountManagementResponsePacket class
     * @param version of this AccountManagementResponsePacket
     */
    public AccountManagementResponsePacket(int version) {
        super(version);
        this.type = PacketTypeKeeper.ACCOUNTMANAGEMENTRESPONSEPACKET;
    }

    /**
     * Methode to set the result, as response to the request, for select statements only
     * @param list with result, null if there was no result (happens on update, insert and delete)
     * to set if they where succesfull use "succesfullAddEditDelete"
     */
    public void setResult(ArrayList<String[]> list) {
        this.result = list;
    }

    /**
     * Methode to get the result of the request that was made, only for select statements
     * @return 
     */
    public ArrayList<String[]> getListWithAccount() {
        return this.result;
    }

    @Override
    public int getType() {
        return this.type;
    }

    @Override
    public String toString() {
        String returnString = super.toString()+"\n";
        if (result != null) {
            for (String[] e : result) {
                for (int n = 1; n < e.length; n++) {
                    System.out.print(e[n] + "\t\t");
                }
                System.out.println();
            }
        }
        return returnString;
    }

    /**
     * Methode to set if the request (in case it was an update, delete or insert) was succesfull
     * positive numeric or succes negative for failure
     * @return the succesfullAddEditDelete
     */
    public int isSuccesfullAddEditDelete() {
        return succesfullAddEditDelete;
    }

    /**
     * Methode to set if the request was succesfully executed
     * positive numeric for succes negative for failure
     * @param succesfullAddEditDelete the succesfullAddEditDelete to set
     */
    public void setSuccesfullAddEditDelete(int succesfullAddEditDelete) {
        this.succesfullAddEditDelete = succesfullAddEditDelete;
    }
}